package com.mes.defece.controller;

import com.mes.defece.service.DefeceService;
import com.mes.pojo.defece.Defece;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 侯伟豪
 * @Company 起点编程
 * @Description
 * @Time 2024/10/16 19:12
 */
@RestController
@CrossOrigin
@RequestMapping("/defece")
public class DefeceController {
    @Autowired
    private DefeceService defeceService;
//    质量缺陷的分页查询
    @GetMapping("/selectAll")
    public Object selectAll(Defece defece, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit){
        return defeceService.selectCount(defece,page,limit);
    }
//    新增缺陷
    @PostMapping("/add")
    public Object add(@RequestBody Defece defece){
        return defeceService.addDefece(defece);
    }
//    根据id查询缺陷数据
    @GetMapping("/selectById")
    public Object selectById(Long defeceId){
        return defeceService.selectById(defeceId);
    }
//    根据id修改缺陷数据
    @PostMapping("/update")
    public Object update(@RequestBody Defece defece){
        return defeceService.updateDefece(defece);
    }
//    根据id删除缺陷数据
    @DeleteMapping("/delete")
    public Object delete(Long defeceId){
        return defeceService.updateDefeceStatus(defeceId,99);
    }
}